package cn.bdqn.service.impl;

import cn.bdqn.domain.DoctorDiagnose;
import cn.bdqn.domain.Recipe;
import cn.bdqn.domain.Registration;
import cn.bdqn.mapper.DoctorDiagnoseMapper;
import cn.bdqn.mapper.RecipeMapper;
import cn.bdqn.mapper.RegistrationMapper;
import cn.bdqn.service.DiagnoseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service

public class DiagnoseServiceImpl implements DiagnoseService {

    @Autowired
    private DoctorDiagnoseMapper doctorDiagnoseMapper;
    @Autowired
    private RegistrationMapper registrationMapper;
    @Autowired
    private RecipeMapper recipeMapper;


    /**
     * 根据挂号编号和科室查询 挂号人员   受理过的
     * @param id  挂号id
     * @param deptId  科室id
     * @return  挂号人信息
     */
    @Override
    public Registration queryByIdAndDeptId(String id, Integer deptId) {
        return registrationMapper.selectByIDAndDeptID(id,deptId);
    }

    /**
     * 根据科室查询挂号人 (所有的 受理过的)
     * @param deptId
     * @return 挂号人集合
     */
    @Override
    public List<Registration> queryByDeptId(Integer deptId) {
        return registrationMapper.selectByRegisDepartments(deptId);
    }

    /**
     * 添加一条诊断信息
     * @param doctorDiagnose 诊断信息封装
     * @return 插入成功返回的行数
     */
    @Override
    @Transactional
    public int addDiagnose(DoctorDiagnose doctorDiagnose) {
        return doctorDiagnoseMapper.insertSelective(doctorDiagnose);
    }

    /**
     * 根据挂号id查询处方  查询病例
     * @param regId
     * @return
     */
    @Override
    public List<Recipe> queryByRegisterId(String regId) {
        return recipeMapper.selectAllByRegisId(regId);
    }

    /**
     * 根据挂号id查询诊断记录  查询病例
     * @param regId
     * @return
     */
    @Override
    public List<DoctorDiagnose> queryDiagnosesByRegId(String regId) {
        return doctorDiagnoseMapper.selectAllByRegisId(regId);
    }


}
